//
//  main.m
//  C11BonjourClient
//
//  Created by 花强 on 2017/12/25.
//  Copyright © 2017年 花强. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "C11BonjourClient.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        /*insert code here...
        NSLog(@"Hello, World!");
        
        //获取当前的运行循环查看信息
        NSRunLoop * loop = [NSRunLoop currentRunLoop];
        
        //创建一个客户端，并将其服务浏览器实例添加到当前的运行循环中
        C11BonjourClient * client = [[C11BonjourClient alloc] init];
        
        //查找指定的服务类型
        [client.serviceBrowser searchForServicesOfType:@"_ipp._tcp." inDomain:@"local."];
        
        //一直循环，直到服务浏览器停止
        while (!client.finishedLoading && [loop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) {
            
        }
        */
        
        //11.7.1 示例代码
        NSTask * task = [[NSTask alloc] init];
        [task setLaunchPath:@"/bin/ls"];
        NSPipe * outPipe = [NSPipe pipe];
        [task setStandardOutput:outPipe];
        [task launch];
        NSData * output = [[outPipe fileHandleForReading] readDataToEndOfFile];
        NSString * lsout = [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding];
        NSLog(@"/bin/ls output:\n%@",lsout);
        
    }
    return 0;
}
